vim.g.mapleader = " "

local custom_keymap = {
    buffer = {
        { "<A-,>", "<cmd>bprevious<CR>", desc = "Previous buffer" },
        { "<A-,>", "<cmd>bnext<CR>", desc = "Next buffer" },
        { '<A-m>', "<cmd>bdelete<CR>", desc = "Close buffer" },

        { '<leader>bh', "<cmd>bprevious<CR>", desc = "Previous buffer" },
        { '<leader>bl', "<cmd>bnext<CR>", desc = "Next buffer"},
        { '<leader>bd', "<cmd>bdelete<CR>", desc = "Close buffer"},

        { '<leader>ир', "<cmd>bprevious<CR>", desc = "Предыдущий буффер" },
        { '<leader>ид', "<cmd>bnext<CR>", desc = "Следующий буффер"},
        { '<leader>ив', "<cmd>bdelete<CR>", desc = "Закрыть буффер"},
    },
    neoformat = {
        { "<Tab>", "<cmd>Neoformat<CR>", desc = "Format code" },

        { "<leader>bf", "<cmd>Neoformat<CR>", desc = "Format code" },
    },
    terminal = {
        { '<leader>tt', "<cmd>ToggleTerm<CR>", desc = "Open terminal" },
        { '<leader>tr', "<cmd>ToggleTerm direction=tab<CR>",
            desc = "Open terminal in separate tab" },
        { '<leader>tf', "<cmd>ToggleTerm direction=float<CR>",
            desc = "Open floating terminal" },
        { '<leader>ts', "<cmd>ToggleTerm direction=vertical size=80<CR>",
            desc = "Open terminal from right" },

        { '<leader>ее', "<cmd>ToggleTerm<CR>", desc = "Открыть терминал" },
        { '<leader>ек', "<cmd>ToggleTerm direction=tab<CR>",
            desc = "Открыть терминал в отдельной вкладке" },
        { '<leader>еа', "<cmd>ToggleTerm direction=float<CR>",
            desc = 'Открыть "летающий" терминал' },
        { '<leader>еы', "<cmd>ToggleTerm direction=vertical size="
            .. tostring(vim.o.columns / 2) .. "<CR>",
            desc = "Открыть терминал справа" },
    },
    neotree = {
        { "<C-c>", "<cmd>Neotree toggle dir=./<CR>",
            desc = "Toggle Neotree" },

        { "<leader>ff", "<cmd>Neotree toggle dir=./<CR>",
            desc = "Toggle Neotree" },

        { "<leader>аа", "<cmd>Neotree toggle dir=./<CR>",
            desc = 'Вызвать Neotree' },
    },
    refactor = {
        { mode = {'v', 'n'}, "<leader>re", "<cmd>Refactor extract<CR>",
            desc = "Extract code to function" },
    },
    telescope = {
        { "<leader>fs", "<cmd>Telescope find_files<CR>", desc = "Search files" },
        { "<leader>fb", "<cmd>Telescope buffers<CR>", desc = "Search buffers" },
    },
    undotree = {
        { "<leader>u", "<cmd>UndotreeToggle<CR>", desc = "Undo tree" },
    },
}

return custom_keymap
